import http from '../utils/http';

// 定义用户响应接口
interface UserResponse {
  user: {
    id: string;
    username: string;
    email: string;
    // 其他用户属性
  };
}

// 用户相关API
export default {
  // 用户注册
  register(userData: any): Promise<UserResponse> {
    return http.post('/users/register', userData);
  },

  // 用户登录
  login(credentials: { username: string, password: string }): Promise<UserResponse> {
    return http.post('/users/login', credentials);
  },

  // 获取用户信息
  getUserInfo() {
    return http.get('/users/me');
  },

  // 更新用户信息
  updateUserInfo(userData: any) {
    return http.put('/users/me', userData);
  },

  // 检查用户名是否存在
  checkUsername(username: string) {
    return http.get('/users/check-username', {
      params: { username }
    });
  },

  // 检查邮箱是否存在
  checkEmail(email: string) {
    return http.get('/users/check-email', {
      params: { email }
    });
  }
};
